VERSION 5.00
Begin VB.Form frmProvincia 
   BackColor       =   &H80000013&
   Caption         =   "Agregar o Modificar Provincias"
   ClientHeight    =   3195
   ClientLeft      =   3060
   ClientTop       =   3450
   ClientWidth     =   4680
   Icon            =   "frmProvincia.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   Begin VB.CommandButton cmdsalir 
      Caption         =   "&Salir (Esc)"
      Height          =   375
      Left            =   3360
      TabIndex        =   7
      Top             =   2400
      Width           =   1095
   End
   Begin VB.CommandButton cmdcancelar 
      Caption         =   "&Cancelar"
      Height          =   375
      Left            =   1800
      TabIndex        =   6
      Top             =   2400
      Width           =   1095
   End
   Begin VB.CommandButton cmdAceptar 
      Caption         =   "&Aceptar"
      Height          =   375
      Left            =   480
      TabIndex        =   5
      Top             =   2400
      Width           =   1095
   End
   Begin VB.TextBox txtnombre 
      Height          =   285
      Left            =   1200
      TabIndex        =   4
      Top             =   1800
      Width           =   2055
   End
   Begin VB.CommandButton cmdmodificar 
      Caption         =   "&Modificar"
      Height          =   375
      Left            =   3480
      TabIndex        =   2
      Top             =   600
      Width           =   975
   End
   Begin VB.CommandButton cmdnuevo 
      Caption         =   "&Nuevo"
      Height          =   375
      Left            =   3480
      TabIndex        =   1
      Top             =   120
      Width           =   975
   End
   Begin VB.ListBox lstprovincia 
      Height          =   1425
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   3135
   End
   Begin VB.Label lblnombre 
      BackColor       =   &H80000013&
      Caption         =   "Nombre:"
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   1800
      Width           =   735
   End
End
Attribute VB_Name = "frmProvincia"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim BAN As Integer

Private Sub cmdAceptar_Click()
    Select Case BAN
    Case 1
        
        ConsultaSql "select * from provincia"
        rs.AddNew
        rs!nombre = txtnombre.text
        rs.Update
        
    Case 2
        
        ConsultaSql "select * from provincia where id_provincia = ' " & lstprovincia.ItemData(lstprovincia.ListIndex) & " '"
        rs!nombre = txtnombre.text
        rs.Update
        
    End Select
    cargarlista
    cmdAceptar.Enabled = False
    cmdCancelar.Enabled = False
    cmdSalir.Enabled = True
    cmdNuevo.Enabled = True
    txtnombre.Enabled = False
    lblnombre.Enabled = False
    lstprovincia.Enabled = True
    txtnombre.text = ""
End Sub

Private Sub cmdCancelar_Click()
lstprovincia.Enabled = True
cmdNuevo.Enabled = True
cmdSalir.Enabled = True
cmdCancelar.Enabled = False
cmdAceptar.Enabled = False
lblnombre.Enabled = False
txtnombre.Enabled = False

End Sub



Private Sub cmdmodificar_Click()
BAN = 2
lstprovincia.Enabled = False
lblnombre.Enabled = True
txtnombre.Enabled = True
cmdAceptar.Enabled = True
cmdCancelar.Enabled = True
cmdmodificar.Enabled = False

cmdNuevo.Enabled = False
cmdSalir.Enabled = False
End Sub

Private Sub cmdnuevo_Click()
BAN = 1
'lstprovincia.ListIndex = -1
lblnombre.Enabled = True
txtnombre.Enabled = True
lstprovincia.Enabled = False
cmdAceptar.Enabled = True
cmdCancelar.Enabled = True
cmdSalir.Enabled = False
cmdmodificar.Enabled = False
cmdNuevo.Enabled = False

txtnombre.text = ""

End Sub

Private Sub cmdSalir_Click()


Unload Me
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then Unload Me
    If KeyAscii = 13 Then
        SendKeys ("{tab}")
        
    End If

End Sub

Private Sub Form_Load()

Me.Height = 3600
Me.Width = 4800

lblnombre.Enabled = False
txtnombre.Enabled = False
cmdAceptar.Enabled = False
cmdCancelar.Enabled = False

cmdmodificar.Enabled = False
cargarlista


End Sub

Private Sub lstprovincia_Click()
txtnombre.text = lstprovincia.List(lstprovincia.ListIndex)
cmdmodificar.Enabled = True

End Sub

Private Sub cargarlista()
lstprovincia.Clear

ConsultaSql "select * from provincia order by nombre"
If rs.RecordCount <> 0 Then
    rs.MoveFirst
    i = 0
    Do While Not rs.EOF
       lstprovincia.AddItem (rs!nombre)
       lstprovincia.ItemData(i) = rs!id_provincia
       i = i + 1
       rs.MoveNext
    Loop
End If
End Sub


